
import axios from '../utils/request'

// axios.defaults.headers.post['Content-Type'] = 'application/json';



// 运行设备
export function run_device() {
    return axios({
        method:'GET',
        url:'task/rundevice.json',
        header: {
            'Content-Type': 'application/json'
        }

    })
}

// 设备停止运行
export function stop_device() {
    return axios({
        method:'GET',
        url:'task/stopdevice.json',
        header: {
            'Content-Type': 'application/json'
        }

    })
}




//邮件测试
export function send_mail() {
    return axios({
        method: 'GET',
        url: 'task/demo',
        header: {
            'Content-Type': 'application/json'
        }
    })
}

//check_status 
export function getstatus(taskid) {
    return axios({
        method: 'POST',
        url: 'task/getstatus.json/',
        data:taskid,
        header:{
            'Content-Type': 'application/json'
        }
     
    })
}

//查询所有的用例 --- 1000个
export function all_testcase() {
    return axios({
        method: 'GET',
        url: 'task/alltestcase.json/',
        header:{
            'Content-Type': 'application/json'
        }
      
    })
}

//下载选择的用例 
export function download() {
    return axios({
        method: 'GET',
        url: 'task/downloadtestcase.json/',
        header:{
            'Content-Type': 'application/json'
        }
      
    })
}


// 模糊匹配testcase 标题
export function designate_testcase(params) {
    return axios({
        method:'POST',
        url:'task/designatetestcase.json/',
        data:params,
        header:{
            'Content-Type': 'application/json'
        }
    })
    
}

// 执行SQL语句
export function runsql(params) {
    return axios({
        method: 'POST',
        url: 'task/runsql.json/',
        data: params

    })
}

// 文件上传
export function uploadfile(data){
    return axios({
        method :"POST",
        url: "task/uploadfile.json/",
        data :data,
        headers: {
            'Content-Type':'multipart/form-data'
        }
      
    })
}

// 文件上传
export function conversionfile(data){
    return axios({
        method :"POST",
        url: "task/conversionfile.json/",
        data :data,
        headers: {
            'Content-Type':'multipart/form-data'
        }
      
    })
}


// 条件覆盖转换成测试用例 下载
export function downloadcoverfile(data){
    return axios({
        method :"POST",
        url: "task/downloadcoverfile.json/",
        data :data,
        responseType: 'blob'
      
    })
}



// api demo下载 
export function downloadapi(data){
    return axios({
        method:'post',
        url:'task/downloadapi.json/',
        responseType: 'blob',
        data:data
    })
}


// 邮件测试
export function email_send() {

    return axios({
        method: 'GET',
        url: 'task/email_test.json/'

    })
}


// 把选择的配置文件，写入配置文件中，要执行的文件路径名称
export function writeconf(data){
    return axios({
        method :"POST",
        url: "task/writeconf.json/",
        data :data
        
    })
}

export function chosetest(){
    return axios({
        method :"get",
        url: "task/chosetest.json/",
        // data :data
        
    })
}




// 邮件测试
export function api_test() {

    return axios({
        method: 'GET',
        url: 'task/pytest.json/'

    })
}




//查询执行过的任务
export function taskquery() {
    return axios({
        method: 'GET',
        url: 'task/querytask.json/',
        header: {
            'Content-Type':'application/json'
        }
    })
}


// 获取测试用例目录文件
export function scriptlist() {
    return axios({
        method: "GET",
        url: "task/getscriptlist.json/",
        header: {
            'Content-Type': 'application/json'
        }


    })
}




//更新单个任务状态
export function taskupstatus(taskid, status) {
    return axios({
        method: 'get',
        url: 'works/v1/task/upstatus/' + taskid + '/' + status,

    }
    )

}


// 启动线程 
export function mysubprocess(command) {
    return axios({
        method: 'POST',
        url: "v1/subproc",
        header: { 'Content-Type': 'application/x-www-form-urlencoded' },
        data: command
    }
    )
}

// 上传文件
export function api_upload(file) {
    return axios({
        method: 'POST',
        url: 'v1/api/upload',
        header: { 'Content-Type': 'multipart/form-data' },
        data: file
    })
}

// 下载
// export function api_download() {
//     return axios({
//         method: 'GET',
//         url: 'v1/api/download',
//         responseType: 'blob',
    
//     })
// }




//export  导出才可以使用